package com.bins.cloud.stream.mq;

import com.alibaba.fastjson.JSON;
import com.bins.cloud.stream.eo.mq.MqMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;

@Slf4j
@Component
public class MqConsumer {

    @Bean
    public Consumer<Message<MqMsg>> consumerB() {
        log.info("consumerB开始接收消息");
        return data -> {
            MqMsg mqMsg = data.getPayload();
            log.info("consumerB 接收一条记录：" + JSON.toJSONString(mqMsg));
        };
    }

}